package com.zzyl.test;

import com.zzyl.nursing.domain.NursingProject;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import java.math.BigDecimal;

@SpringBootTest
public class RedisTest2 {

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @Test
    public void test(){
        NursingProject nursingProject = new NursingProject();
        nursingProject.setId(10L);
        nursingProject.setName("洗衣服");
        nursingProject.setPrice(new BigDecimal(10));

        redisTemplate.opsForValue().set("nursing_project", nursingProject);

        //取出对象
        NursingProject np = (NursingProject) redisTemplate.opsForValue().get("nursing_project");
        System.out.println(np);
    }
}
